package chixing.day12.work.w1;

import java.util.ArrayList;
import java.util.List;

public class CourseManager {
    private List<Course> courseList;
    public CourseManager() {
        courseList = new ArrayList<>();
    }
    public void add(Course course){
        courseList.add(course);
        System.out.println("添加课程成功！");
    }
    public boolean replacecourse(){
        for(int i=0;i<courseList.size();i++){
            if(courseList.get(i).getCourseName().equals("数据库原理")){
                courseList.get(i).setCourseName("数据结构");
                System.out.println("修改课程成功！");
                return true;
            }
        }
        return false;
    }
    public boolean remove(String courseId){
        int lowscoreindex = 0;
        double lowscore = courseList.get(0).getCourseScore();
        for(int i=0;i<courseList.size();i++){
            if(courseList.get(i).getCourseScore()<lowscore){
                lowscore = courseList.get(i).getCourseScore();
                lowscoreindex = i;
            }
        }
        courseList.remove(lowscoreindex);
        System.out.println("删除课程成功！");
        return true;
    }
    public void displayAllCourses(){
        for(Course course:courseList){
            System.out.println(course);
        }
    }

}
